Imports AppliedRecognition.Util

Public Class QSBaseForm
    Inherits System.Windows.Forms.Form



    Sub New()
        MyBase.New()

        InitializeComponent()

    End Sub

#Region " Windows Form Designer generated code "

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents HideFormTimer As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.HideFormTimer = New System.Windows.Forms.Timer(Me.components)
        '
        'QSBaseForm
        '
        Me.Name = "QSBaseForm"
        Me.Text = "QSBaseForm"
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(152, Byte), CType(112, Byte), CType(180, Byte))
        Me.ClientSize = New System.Drawing.Size(806, 470)
        Me.ControlBox = False
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.KeyPreview = True
        Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
    End Sub

#End Region

    Private Sub HideFormTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideFormTimer.Tick
        DoHide()
        Me.Close()
    End Sub

    Protected Overridable Sub DoHide()
        HideFormTimer.Enabled = False
        Me.Hide()
    End Sub


    Protected Friend ReadOnly Property Dispatch() As CommandDispatch
        Get
            Return CommandDispatch.DefaultInstance
        End Get
    End Property

#Region "   Keyboard support"
    Friend Sub _KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Escape Then
            Me.Hide()
            Me.Close()
        End If
    End Sub

#End Region

    Protected formShowed As Boolean
    Public Sub ShowForm()
        Try
            If Not ShowFormSetup() Then
                Exit Sub
            End If

            HideFormTimer.Interval = My.MySettings.Default.DisplayTimout
            Me.Icon = QSRes.QSIcon

            If formShowed Then
                HideFormTimer.Stop()
                HideFormTimer.Start()
            End If

            formShowed = True
            Me.Icon = QSRes.QSIcon
            HideFormTimer.Start()
            Me.Show()
            Me.BringToFront()
            Me.TopMost = True
            Me.TopMost = False
        Finally
            Trace.Unindent()
        End Try
    End Sub

    Protected Overridable Function ShowFormSetup() As Boolean
        Return False
    End Function



End Class
